package com.example.abc;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class zc extends AppCompatActivity {
    private EditText userEditText;
    private EditText passwordEditText;
    private EditText ageEditText;
    private EditText nickEditText;
    private Button regBtn;
    private Button backBtn;
    Intent resultIntent = new Intent();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        userEditText = findViewById(R.id.regUserEditText);
        passwordEditText = findViewById(R.id.regPasswordEditText);
        ageEditText = findViewById(R.id.regAgeEditText);
        nickEditText = findViewById(R.id.regNickEditText);
        regBtn = findViewById(R.id.regRegBtn);
        backBtn = findViewById(R.id.regBackBtn);

        regBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String yhm;
                String mm;
                String nl;
                String xm;

                yhm = userEditText.getText().toString();



                mm = passwordEditText.getText().toString();

                nl = ageEditText.getText().toString();


                xm = nickEditText.getText().toString();


                if (null != glq.getUser(getApplicationContext(), yhm)) {
                    
                    Toast.makeText(zc.this, "用户名已存在", Toast.LENGTH_SHORT).show();
                    return;
                }

                resultIntent.putExtra("yhm", yhm);
                resultIntent.putExtra("mm", mm);
                glq.zhuce(getApplicationContext(), new yh(yhm, mm, xm, Integer.parseInt(nl)
                ));
                setResult(1, resultIntent);
                Toast.makeText(zc.this, "注册成功", Toast.LENGTH_SHORT).show();
            }
        });

        backBtn.setOnClickListener(new View.OnClickListener() {
            @Override


            public void onClick(View v) {
                finish();

            }
        });
    }
}